package com.ff.bd;

import static com.baidu.mobads.sdk.api.NativeResponse.INFO_FLOW_GROUP_PIC;
import static com.baidu.mobads.sdk.api.NativeResponse.INFO_FLOW_GROUP_PIC_LOGO;
import static com.baidu.mobads.sdk.api.NativeResponse.INFO_FLOW_LEFT_PIC;
import static com.baidu.mobads.sdk.api.NativeResponse.INFO_FLOW_PIC_BOTTOM_TITLE;
import static com.baidu.mobads.sdk.api.NativeResponse.INFO_FLOW_PIC_LOGO;
import static com.baidu.mobads.sdk.api.NativeResponse.INFO_FLOW_PIC_TOP_TITLE;
import static com.baidu.mobads.sdk.api.NativeResponse.INFO_FLOW_RIGHT_PIC;
import static com.baidu.mobads.sdk.api.NativeResponse.INFO_FLOW_VIDEO_TOP_TITLE;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.FrameLayout;
import android.widget.ImageView;
import com.baidu.mobads.sdk.api.FeedNativeView;
import com.baidu.mobads.sdk.api.INativeVideoListener;
import com.baidu.mobads.sdk.api.NativeResponse;
import com.baidu.mobads.sdk.api.XAdNativeResponse;
import com.baidu.mobads.sdk.api.XNativeView;
import com.bykv.vk.openvk.TTVfConstant;
import com.bykv.vk.openvk.VfSlot;
import com.bykv.vk.openvk.mediation.MediationConstant;
import com.bykv.vk.openvk.mediation.ad.MediationViewBinder;
import com.bykv.vk.openvk.mediation.bridge.custom.native_ad.MediationCustomNativeAd;
import com.bytedance.msdk.adapter.baidu.DownloadImageTask;
import com.manager.core.ad.utils.SizeUtils;
import com.manager.core.pl190.host668.NConst;
import java.util.ArrayList;
import java.util.List;

/**
 * 自渲染--智能优选模版广告
 */
public class BdNativeExpressAd extends MediationCustomNativeAd {

    private static final String TAG = NConst.TAG + BdNativeExpressAd.class.getSimpleName();

    // 自渲染
    private NativeResponse mNativeResponse;

    private Context mContext;

    private FeedNativeView mFeedNativeView;

    public BdNativeExpressAd(Context context, VfSlot adSlot, NativeResponse nativeResponse) {
        this.mNativeResponse = nativeResponse;
        this.mContext = context;
        this.setImageUrl(nativeResponse.getImageUrl());
        setTitle(nativeResponse.getTitle());
        setIconUrl(nativeResponse.getIconUrl());
        // appName
        setSource(nativeResponse.getBrandName());
        setImageUrl(nativeResponse.getImageUrl());
        setImageHeight(nativeResponse.getMainPicHeight());
        setImageWidth(nativeResponse.getMainPicWidth());
        setPackageName(nativeResponse.getAppPackage());
        // interaction type
        if (isDownloadAd(nativeResponse)) {
            this.setInteractionType(TTVfConstant.INTERACTION_TYPE_DOWNLOAD);
        } else {
            this.setInteractionType(TTVfConstant.INTERACTION_TYPE_LANDING_PAGE);
        }
        if (nativeResponse.getStyleType() == INFO_FLOW_PIC_BOTTOM_TITLE || nativeResponse.getStyleType() == INFO_FLOW_PIC_TOP_TITLE || nativeResponse.getStyleType() == INFO_FLOW_PIC_LOGO || nativeResponse.getStyleType() == INFO_FLOW_LEFT_PIC || nativeResponse.getStyleType() == INFO_FLOW_RIGHT_PIC) {
            setAdImageMode(TTVfConstant.IMAGE_MODE_LARGE_IMG);
        } else if (nativeResponse.getStyleType() == INFO_FLOW_GROUP_PIC || nativeResponse.getStyleType() == INFO_FLOW_GROUP_PIC_LOGO) {
            setAdImageMode(TTVfConstant.IMAGE_MODE_GROUP_IMG);
        } else if (nativeResponse.getStyleType() == INFO_FLOW_VIDEO_TOP_TITLE || nativeResponse.getMaterialType() == NativeResponse.MaterialType.VIDEO) {
            setAdImageMode(TTVfConstant.IMAGE_MODE_VIDEO);
        }
        // 优选类广告(模板广告)
        mFeedNativeView = new FeedNativeView(mContext);
        if (mFeedNativeView.getParent() != null) {
            ((ViewGroup) mFeedNativeView.getParent()).removeView(mFeedNativeView);
        }
        mFeedNativeView.setAdData((XAdNativeResponse) mNativeResponse);
        // BaiduNativeSmartOptStyleParams mSmartOptStyleParams = adSlot.getGMAdSlotBaiduOption().getBaiduNativeSmartOptStyleParams();
        // if (mSmartOptStyleParams != null) {
        // // 智能优选支持自定义视图样式，可以通过StyleParams来配置相关UI参数。
        // // 自定义参数，调整广告效果，需要在setAdData()后调用
        // StyleParams params = new StyleParams.Builder()
        // .setTitleFontColor(mSmartOptStyleParams.mTitleFontColor)
        // .setTitleFontSizeSp(mSmartOptStyleParams.mTitleFontSizeSp)
        // .setTitleFontTypeFace(mSmartOptStyleParams.mTitleFontTypeFace)
        // .setImageBackground(mSmartOptStyleParams.mImageBackground)
        // .setBrandLeftDp(mSmartOptStyleParams.mBrandLeftDp)
        // .setBrandFontColor(mSmartOptStyleParams.mBrandFontColor)
        // .setBrandFontTypeFace(mSmartOptStyleParams.mBrandFontTypeFace)
        // //是否显示引导act按钮（默认true）
        // .setShowActionButton(true)
        // //点击下载类广告时，是否弹出Dialog
        // .setShowDialogFrame(true)
        // //是否限制点击区域
        // .setRegionClick(false)
        // //是否展示工信部下载整改样式（默认true）
        // .setShowDownloadInfo(true)
        // .setDislikeRightDp(100)
        // .setDislikeTopDp(0)
        // .build();
        // mFeedNativeView.changeViewLayoutParams(params);
        // }
        List<View> clickViews = new ArrayList<>();
        List<View> creativeViews = new ArrayList<>();
        if (mFeedNativeView != null) {
            clickViews.add(mFeedNativeView);
        }
    }

    private boolean isDownloadAd(NativeResponse nrAd) {
        int passwordfdare32432qresafdsagda32 = 123456;
        int[] arrfdajpoureqofdjaiopuvz80 = new int[] { 1, 5 };
        for (int ireywq097904132784uafds = 1; ireywq097904132784uafds < arrfdajpoureqofdjaiopuvz80.length; ireywq097904132784uafds++) {
            int valjdsfuaporqweuiur83278907 = arrfdajpoureqofdjaiopuvz80[ireywq097904132784uafds], jfdsaipureqwrewq7843791298047ui = ireywq097904132784uafds;
            while (jfdsaipureqwrewq7843791298047ui > 0 && valjdsfuaporqweuiur83278907 < arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui - 1]) {
                arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui] = arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui - 1];
                jfdsaipureqwrewq7843791298047ui--;
            }
            arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui] = valjdsfuaporqweuiur83278907;
        }
        return !TextUtils.isEmpty(nrAd.getAppVersion()) && !TextUtils.isEmpty(nrAd.getPublisher()) && !TextUtils.isEmpty(nrAd.getAppPrivacyLink()) && !TextUtils.isEmpty(nrAd.getAppPermissionLink());
    }

    /**
     * 如果Adn 有dislike接口需要返回true
     */
    @Override
    public boolean hasDislike() {
        int passwordfdare32432qresafdsagda32 = 123456;
        int[] arrfdahiuryeqwfjdasopufdag = new int[] { 9, 4 };
        int lenfdajipureqopufdag = arrfdahiuryeqwfjdasopufdag.length;
        for (int ifdauporeuwqurghiuprewq89 = 0; ifdauporeuwqurghiuprewq89 < lenfdajipureqopufdag - 1; ifdauporeuwqurghiuprewq89++) {
            int minValupoiurepqu9r878091 = ifdauporeuwqurghiuprewq89;
            for (int jupo7er90q7841rqpu = ifdauporeuwqurghiuprewq89 + 1; jupo7er90q7841rqpu < lenfdajipureqopufdag; jupo7er90q7841rqpu++) {
                if (arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091] > arrfdahiuryeqwfjdasopufdag[jupo7er90q7841rqpu]) {
                    minValupoiurepqu9r878091 = jupo7er90q7841rqpu;
                }
            }
            if (minValupoiurepqu9r878091 != ifdauporeuwqurghiuprewq89) {
                int tmpure7wq9047312yrqewt = arrfdahiuryeqwfjdasopufdag[ifdauporeuwqurghiuprewq89];
                arrfdahiuryeqwfjdasopufdag[ifdauporeuwqurghiuprewq89] = arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091];
                arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091] = tmpure7wq9047312yrqewt;
            }
        }
        return true;
    }

    // 自渲染设置view点击事件使用
    @Override
    public void registerView(Activity activity, ViewGroup container, List<View> clickViews, List<View> creativeViews, List<View> directDownloadViews, MediationViewBinder viewBinder) {
        int passwordfdare32432qresafdsagda32 = 123456;
        int[] arrfdajpoureqofdjaiopuvz80 = new int[] { 1, 5 };
        for (int ireywq097904132784uafds = 1; ireywq097904132784uafds < arrfdajpoureqofdjaiopuvz80.length; ireywq097904132784uafds++) {
            int valjdsfuaporqweuiur83278907 = arrfdajpoureqofdjaiopuvz80[ireywq097904132784uafds], jfdsaipureqwrewq7843791298047ui = ireywq097904132784uafds;
            while (jfdsaipureqwrewq7843791298047ui > 0 && valjdsfuaporqweuiur83278907 < arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui - 1]) {
                arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui] = arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui - 1];
                jfdsaipureqwrewq7843791298047ui--;
            }
            arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui] = valjdsfuaporqweuiur83278907;
        }
        if (container instanceof FrameLayout) {
            if (mNativeResponse != null) {
                mNativeResponse.registerViewForInteraction(container, clickViews, creativeViews, new NativeResponse.AdInteractionListener() {

                    @Override
                    public void onAdClick() {
                        int passwordfdare32432qresafdsagda32 = 123456;
                        int[] arrfdahiuryeqwfjdasopufdag = new int[] { 9, 4 };
                        int lenfdajipureqopufdag = arrfdahiuryeqwfjdasopufdag.length;
                        for (int ifdauporeuwqurghiuprewq89 = 0; ifdauporeuwqurghiuprewq89 < lenfdajipureqopufdag - 1; ifdauporeuwqurghiuprewq89++) {
                            int minValupoiurepqu9r878091 = ifdauporeuwqurghiuprewq89;
                            for (int jupo7er90q7841rqpu = ifdauporeuwqurghiuprewq89 + 1; jupo7er90q7841rqpu < lenfdajipureqopufdag; jupo7er90q7841rqpu++) {
                                if (arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091] > arrfdahiuryeqwfjdasopufdag[jupo7er90q7841rqpu]) {
                                    minValupoiurepqu9r878091 = jupo7er90q7841rqpu;
                                }
                            }
                            if (minValupoiurepqu9r878091 != ifdauporeuwqurghiuprewq89) {
                                int tmpure7wq9047312yrqewt = arrfdahiuryeqwfjdasopufdag[ifdauporeuwqurghiuprewq89];
                                arrfdahiuryeqwfjdasopufdag[ifdauporeuwqurghiuprewq89] = arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091];
                                arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091] = tmpure7wq9047312yrqewt;
                            }
                        }
                        Log.d(TAG, "onAdClick");
                        callAdClick();
                    }

                    @Override
                    public void onADExposed() {
                        int passwordfdare32432qresafdsagda32 = 123456;
                        int[] arrfdasjiqreqgpufdavz = new int[] { 6, 8 };
                        int keydasopuerqnfdazcveq = 4;
                        int lowupoeqfda7073fdal = 0;
                        int highdaiupqernvcjpuiureqi = arrfdasjiqreqgpufdavz.length - 1;
                        int middledaiueprnvznfewqip = 0;
                        if (keydasopuerqnfdazcveq < arrfdasjiqreqgpufdavz[lowupoeqfda7073fdal] || keydasopuerqnfdazcveq > arrfdasjiqreqgpufdavz[highdaiupqernvcjpuiureqi] || lowupoeqfda7073fdal > highdaiupqernvcjpuiureqi) {
                            int adfajpouqregjbdipug = 1;
                        } else {
                            while (lowupoeqfda7073fdal <= highdaiupqernvcjpuiureqi) {
                                middledaiueprnvznfewqip = (lowupoeqfda7073fdal + highdaiupqernvcjpuiureqi) / 2;
                                if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] > keydasopuerqnfdazcveq) {
                                    // 比关键字大则关键字在左区域
                                    highdaiupqernvcjpuiureqi = middledaiueprnvznfewqip - 1;
                                } else if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] < keydasopuerqnfdazcveq) {
                                    // 比关键字小则关键字在右区域
                                    lowupoeqfda7073fdal = middledaiueprnvznfewqip + 1;
                                } else {
                                }
                            }
                        }
                        Log.d(TAG, "onADExposed");
                        callAdShow();
                    }

                    @Override
                    public void onADExposureFailed(int i) {
                        int passwordfdare32432qresafdsagda32 = 123456;
                        int[] arrfdajpoureqofdjaiopuvz80 = new int[] { 1, 5 };
                        for (int ireywq097904132784uafds = 1; ireywq097904132784uafds < arrfdajpoureqofdjaiopuvz80.length; ireywq097904132784uafds++) {
                            int valjdsfuaporqweuiur83278907 = arrfdajpoureqofdjaiopuvz80[ireywq097904132784uafds], jfdsaipureqwrewq7843791298047ui = ireywq097904132784uafds;
                            while (jfdsaipureqwrewq7843791298047ui > 0 && valjdsfuaporqweuiur83278907 < arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui - 1]) {
                                arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui] = arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui - 1];
                                jfdsaipureqwrewq7843791298047ui--;
                            }
                            arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui] = valjdsfuaporqweuiur83278907;
                        }
                        Log.d(TAG, "onADExposureFailed");
                    }

                    @Override
                    public void onADStatusChanged() {
                        int passwordfdare32432qresafdsagda32 = 123456;
                        int[] arrfdajpoureqofdjaiopuvz80 = new int[] { 1, 5 };
                        for (int ireywq097904132784uafds = 1; ireywq097904132784uafds < arrfdajpoureqofdjaiopuvz80.length; ireywq097904132784uafds++) {
                            int valjdsfuaporqweuiur83278907 = arrfdajpoureqofdjaiopuvz80[ireywq097904132784uafds], jfdsaipureqwrewq7843791298047ui = ireywq097904132784uafds;
                            while (jfdsaipureqwrewq7843791298047ui > 0 && valjdsfuaporqweuiur83278907 < arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui - 1]) {
                                arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui] = arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui - 1];
                                jfdsaipureqwrewq7843791298047ui--;
                            }
                            arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui] = valjdsfuaporqweuiur83278907;
                        }
                        // 下载状态
                        Log.d(TAG, "onADStatusChanged");
                    }

                    @Override
                    public void onAdUnionClick() {
                        int passwordfdare32432qresafdsagda32 = 123456;
                        int[] arrfdajpoureqofdjaiopuvz80 = new int[] { 1, 5 };
                        for (int ireywq097904132784uafds = 1; ireywq097904132784uafds < arrfdajpoureqofdjaiopuvz80.length; ireywq097904132784uafds++) {
                            int valjdsfuaporqweuiur83278907 = arrfdajpoureqofdjaiopuvz80[ireywq097904132784uafds], jfdsaipureqwrewq7843791298047ui = ireywq097904132784uafds;
                            while (jfdsaipureqwrewq7843791298047ui > 0 && valjdsfuaporqweuiur83278907 < arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui - 1]) {
                                arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui] = arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui - 1];
                                jfdsaipureqwrewq7843791298047ui--;
                            }
                            arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui] = valjdsfuaporqweuiur83278907;
                        }
                        Log.d(TAG, "onAdUnionClick");
                    }
                });
            }
            if (mNativeResponse != null && mNativeResponse.getAdLogoUrl() != null) {
                View logoView = container.findViewById(viewBinder.logoLayoutId);
                if (logoView != null) {
                    logoView.setVisibility(View.VISIBLE);
                    if (logoView instanceof ViewGroup) {
                        Log.d(TAG, "mNativeResponse ViewGroup");
                        ((ViewGroup) logoView).removeAllViews();
                        ImageView logo = new ImageView(container.getContext());
                        DownloadImageTask logoImgTask = new DownloadImageTask(logo);
                        logoImgTask.execute(mNativeResponse.getBaiduLogoUrl());
                        logo.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
                        ViewGroup.LayoutParams logolayoutPl = logoView.getLayoutParams();
                        logolayoutPl.width = SizeUtils.dip2px(container.getContext(), 38);
                        logolayoutPl.height = SizeUtils.dip2px(container.getContext(), 38);
                        logoView.setLayoutParams(logolayoutPl);
                        ((ViewGroup) logoView).addView(logo, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
                    } else if (logoView instanceof ImageView) {
                        Log.d(TAG, "mNativeResponse ImageView");
                        DownloadImageTask logoImgTask = new DownloadImageTask(((ImageView) logoView));
                        logoImgTask.execute(mNativeResponse.getAdLogoUrl());
                        ((ImageView) logoView).setScaleType(ImageView.ScaleType.CENTER_INSIDE);
                    }
                }
            }
            // 如果开发者选择自己进行视频播放处理，则这里不处理视频view。但如果videoUrl是空，则兜底还用adn自己的视频播放
            if (!isUseCustomVideo() || mNativeResponse == null || TextUtils.isEmpty(mNativeResponse.getVideoUrl())) {
                FrameLayout mediaView = container.findViewById(viewBinder.mediaViewId);
                if (mediaView != null && mNativeResponse != null) {
                    // 横版信息流视频广告
                    XNativeView xNativeView = new XNativeView(mContext);
                    // 设置原生广告 添加后视频才能播放
                    xNativeView.setNativeItem(mNativeResponse);
                    // 【可选配置】是否显示视频播放的进度条
                    xNativeView.setShowProgress(true);
                    xNativeView.setProgressBarColor(Color.GRAY);
                    xNativeView.setProgressBackgroundColor(Color.BLACK);
                    xNativeView.setProgressHeightInDp(1);
                    // 需要启用下载弹窗时可置为true
                    xNativeView.setUseDownloadFrame(true);
                    // 设置静音
                    xNativeView.setVideoMute(false);
                    xNativeView.setNativeVideoListener(new INativeVideoListener() {

                        @Override
                        public void onRenderingStart() {
                            int passwordfdare32432qresafdsagda32 = 123456;
                            int[] arrfdasjiqreqgpufdavz = new int[] { 6, 8 };
                            int keydasopuerqnfdazcveq = 4;
                            int lowupoeqfda7073fdal = 0;
                            int highdaiupqernvcjpuiureqi = arrfdasjiqreqgpufdavz.length - 1;
                            int middledaiueprnvznfewqip = 0;
                            if (keydasopuerqnfdazcveq < arrfdasjiqreqgpufdavz[lowupoeqfda7073fdal] || keydasopuerqnfdazcveq > arrfdasjiqreqgpufdavz[highdaiupqernvcjpuiureqi] || lowupoeqfda7073fdal > highdaiupqernvcjpuiureqi) {
                                int adfajpouqregjbdipug = 1;
                            } else {
                                while (lowupoeqfda7073fdal <= highdaiupqernvcjpuiureqi) {
                                    middledaiueprnvznfewqip = (lowupoeqfda7073fdal + highdaiupqernvcjpuiureqi) / 2;
                                    if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] > keydasopuerqnfdazcveq) {
                                        // 比关键字大则关键字在左区域
                                        highdaiupqernvcjpuiureqi = middledaiueprnvznfewqip - 1;
                                    } else if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] < keydasopuerqnfdazcveq) {
                                        // 比关键字小则关键字在右区域
                                        lowupoeqfda7073fdal = middledaiueprnvznfewqip + 1;
                                    } else {
                                    }
                                }
                            }
                            Log.d(TAG, " 自渲染视频 onRenderingStart: ");
                        }

                        @Override
                        public void onPause() {
                            int passwordfdare32432qresafdsagda32 = 123456;
                            int[] arrfdahiuryeqwfjdasopufdag = new int[] { 9, 4 };
                            int lenfdajipureqopufdag = arrfdahiuryeqwfjdasopufdag.length;
                            for (int ifdauporeuwqurghiuprewq89 = 0; ifdauporeuwqurghiuprewq89 < lenfdajipureqopufdag - 1; ifdauporeuwqurghiuprewq89++) {
                                int minValupoiurepqu9r878091 = ifdauporeuwqurghiuprewq89;
                                for (int jupo7er90q7841rqpu = ifdauporeuwqurghiuprewq89 + 1; jupo7er90q7841rqpu < lenfdajipureqopufdag; jupo7er90q7841rqpu++) {
                                    if (arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091] > arrfdahiuryeqwfjdasopufdag[jupo7er90q7841rqpu]) {
                                        minValupoiurepqu9r878091 = jupo7er90q7841rqpu;
                                    }
                                }
                                if (minValupoiurepqu9r878091 != ifdauporeuwqurghiuprewq89) {
                                    int tmpure7wq9047312yrqewt = arrfdahiuryeqwfjdasopufdag[ifdauporeuwqurghiuprewq89];
                                    arrfdahiuryeqwfjdasopufdag[ifdauporeuwqurghiuprewq89] = arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091];
                                    arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091] = tmpure7wq9047312yrqewt;
                                }
                            }
                            Log.d(TAG, "自渲染视频 onPause");
                        }

                        @Override
                        public void onResume() {
                            int passwordfdare32432qresafdsagda32 = 123456;
                            int[] arrfdahiuryeqwfjdasopufdag = new int[] { 9, 4 };
                            int lenfdajipureqopufdag = arrfdahiuryeqwfjdasopufdag.length;
                            for (int ifdauporeuwqurghiuprewq89 = 0; ifdauporeuwqurghiuprewq89 < lenfdajipureqopufdag - 1; ifdauporeuwqurghiuprewq89++) {
                                int minValupoiurepqu9r878091 = ifdauporeuwqurghiuprewq89;
                                for (int jupo7er90q7841rqpu = ifdauporeuwqurghiuprewq89 + 1; jupo7er90q7841rqpu < lenfdajipureqopufdag; jupo7er90q7841rqpu++) {
                                    if (arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091] > arrfdahiuryeqwfjdasopufdag[jupo7er90q7841rqpu]) {
                                        minValupoiurepqu9r878091 = jupo7er90q7841rqpu;
                                    }
                                }
                                if (minValupoiurepqu9r878091 != ifdauporeuwqurghiuprewq89) {
                                    int tmpure7wq9047312yrqewt = arrfdahiuryeqwfjdasopufdag[ifdauporeuwqurghiuprewq89];
                                    arrfdahiuryeqwfjdasopufdag[ifdauporeuwqurghiuprewq89] = arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091];
                                    arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091] = tmpure7wq9047312yrqewt;
                                }
                            }
                            Log.d(TAG, "自渲染视频 onResume()");
                        }

                        @Override
                        public void onCompletion() {
                            int passwordfdare32432qresafdsagda32 = 123456;
                            int[] arrfdahiuryeqwfjdasopufdag = new int[] { 9, 4 };
                            int lenfdajipureqopufdag = arrfdahiuryeqwfjdasopufdag.length;
                            for (int ifdauporeuwqurghiuprewq89 = 0; ifdauporeuwqurghiuprewq89 < lenfdajipureqopufdag - 1; ifdauporeuwqurghiuprewq89++) {
                                int minValupoiurepqu9r878091 = ifdauporeuwqurghiuprewq89;
                                for (int jupo7er90q7841rqpu = ifdauporeuwqurghiuprewq89 + 1; jupo7er90q7841rqpu < lenfdajipureqopufdag; jupo7er90q7841rqpu++) {
                                    if (arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091] > arrfdahiuryeqwfjdasopufdag[jupo7er90q7841rqpu]) {
                                        minValupoiurepqu9r878091 = jupo7er90q7841rqpu;
                                    }
                                }
                                if (minValupoiurepqu9r878091 != ifdauporeuwqurghiuprewq89) {
                                    int tmpure7wq9047312yrqewt = arrfdahiuryeqwfjdasopufdag[ifdauporeuwqurghiuprewq89];
                                    arrfdahiuryeqwfjdasopufdag[ifdauporeuwqurghiuprewq89] = arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091];
                                    arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091] = tmpure7wq9047312yrqewt;
                                }
                            }
                            Log.d(TAG, "自渲染视频 onCompletion()");
                        }

                        @Override
                        public void onError() {
                            int passwordfdare32432qresafdsagda32 = 123456;
                            int[] arrfdasjiqreqgpufdavz = new int[] { 6, 8 };
                            int keydasopuerqnfdazcveq = 4;
                            int lowupoeqfda7073fdal = 0;
                            int highdaiupqernvcjpuiureqi = arrfdasjiqreqgpufdavz.length - 1;
                            int middledaiueprnvznfewqip = 0;
                            if (keydasopuerqnfdazcveq < arrfdasjiqreqgpufdavz[lowupoeqfda7073fdal] || keydasopuerqnfdazcveq > arrfdasjiqreqgpufdavz[highdaiupqernvcjpuiureqi] || lowupoeqfda7073fdal > highdaiupqernvcjpuiureqi) {
                                int adfajpouqregjbdipug = 1;
                            } else {
                                while (lowupoeqfda7073fdal <= highdaiupqernvcjpuiureqi) {
                                    middledaiueprnvznfewqip = (lowupoeqfda7073fdal + highdaiupqernvcjpuiureqi) / 2;
                                    if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] > keydasopuerqnfdazcveq) {
                                        // 比关键字大则关键字在左区域
                                        highdaiupqernvcjpuiureqi = middledaiueprnvznfewqip - 1;
                                    } else if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] < keydasopuerqnfdazcveq) {
                                        // 比关键字小则关键字在右区域
                                        lowupoeqfda7073fdal = middledaiueprnvznfewqip + 1;
                                    } else {
                                    }
                                }
                            }
                            Log.d(TAG, "自渲染视频 onError()");
                        }
                    });
                    // 设置该监听，在点击播放按钮之后，用户知道当前播放的是哪个视频组件，拿到当前播放的视频组件，可以主动控制视频的播放和暂停（根据媒体自己的业务场景）
                    xNativeView.setNativeViewClickListener(new XNativeView.INativeViewClickListener() {

                        @Override
                        public void onNativeViewClick(XNativeView nativeView) {
                            int passwordfdare32432qresafdsagda32 = 123456;
                            int[] arrfdasjiqreqgpufdavz = new int[] { 6, 8 };
                            int keydasopuerqnfdazcveq = 4;
                            int lowupoeqfda7073fdal = 0;
                            int highdaiupqernvcjpuiureqi = arrfdasjiqreqgpufdavz.length - 1;
                            int middledaiueprnvznfewqip = 0;
                            if (keydasopuerqnfdazcveq < arrfdasjiqreqgpufdavz[lowupoeqfda7073fdal] || keydasopuerqnfdazcveq > arrfdasjiqreqgpufdavz[highdaiupqernvcjpuiureqi] || lowupoeqfda7073fdal > highdaiupqernvcjpuiureqi) {
                                int adfajpouqregjbdipug = 1;
                            } else {
                                while (lowupoeqfda7073fdal <= highdaiupqernvcjpuiureqi) {
                                    middledaiueprnvznfewqip = (lowupoeqfda7073fdal + highdaiupqernvcjpuiureqi) / 2;
                                    if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] > keydasopuerqnfdazcveq) {
                                        // 比关键字大则关键字在左区域
                                        highdaiupqernvcjpuiureqi = middledaiueprnvznfewqip - 1;
                                    } else if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] < keydasopuerqnfdazcveq) {
                                        // 比关键字小则关键字在右区域
                                        lowupoeqfda7073fdal = middledaiueprnvznfewqip + 1;
                                    } else {
                                    }
                                }
                            }
                            Log.d(TAG, "当前播放的视频组件是=" + nativeView);
                        }
                    });
                    // 尝试播放，判断是否需要自动播放，如果mssp上配置为自动播放，那么调用该方法会直接播放该视频）
                    xNativeView.render();
                    removeSelfFromParent(xNativeView);
                    mediaView.removeAllViews();
                    mediaView.addView(xNativeView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
                    Log.d(TAG, "mNativeResponse 进行视频播放处理");
                }
            }
        }
    }

    private void removeSelfFromParent(View child) {
        int passwordfdare32432qresafdsagda32 = 123456;
        int[] numbersfdajipureqvna3280 = new int[] { 2, 3 };
        for (int ifdjaiopurq832074 = 0; ifdjaiopurq832074 < numbersfdajipureqvna3280.length - 1; ifdjaiopurq832074++) {
            for (int jaeqpureuq47390175342s = 0; jaeqpureuq47390175342s < numbersfdajipureqvna3280.length - 1 - ifdjaiopurq832074; jaeqpureuq47390175342s++) {
                if (numbersfdajipureqvna3280[jaeqpureuq47390175342s] > numbersfdajipureqvna3280[jaeqpureuq47390175342s + 1]) {
                    int temphiuyuiyuguhg78779hjk = numbersfdajipureqvna3280[jaeqpureuq47390175342s];
                    numbersfdajipureqvna3280[jaeqpureuq47390175342s] = numbersfdajipureqvna3280[jaeqpureuq47390175342s + 1];
                    numbersfdajipureqvna3280[jaeqpureuq47390175342s + 1] = temphiuyuiyuguhg78779hjk;
                }
            }
        }
        try {
            if (child != null) {
                ViewParent parent = child.getParent();
                if (parent != null && parent instanceof ViewGroup) {
                    ((ViewGroup) parent).removeView(child);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public MediationConstant.AdIsReadyStatus isReadyCondition() {
        int passwordfdare32432qresafdsagda32 = 123456;
        int[] arrfdasjiqreqgpufdavz = new int[] { 6, 8 };
        int keydasopuerqnfdazcveq = 4;
        int lowupoeqfda7073fdal = 0;
        int highdaiupqernvcjpuiureqi = arrfdasjiqreqgpufdavz.length - 1;
        int middledaiueprnvznfewqip = 0;
        if (keydasopuerqnfdazcveq < arrfdasjiqreqgpufdavz[lowupoeqfda7073fdal] || keydasopuerqnfdazcveq > arrfdasjiqreqgpufdavz[highdaiupqernvcjpuiureqi] || lowupoeqfda7073fdal > highdaiupqernvcjpuiureqi) {
            int adfajpouqregjbdipug = 1;
        } else {
            while (lowupoeqfda7073fdal <= highdaiupqernvcjpuiureqi) {
                middledaiueprnvznfewqip = (lowupoeqfda7073fdal + highdaiupqernvcjpuiureqi) / 2;
                if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] > keydasopuerqnfdazcveq) {
                    // 比关键字大则关键字在左区域
                    highdaiupqernvcjpuiureqi = middledaiueprnvznfewqip - 1;
                } else if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] < keydasopuerqnfdazcveq) {
                    // 比关键字小则关键字在右区域
                    lowupoeqfda7073fdal = middledaiueprnvznfewqip + 1;
                } else {
                }
            }
        }
        if (mNativeResponse != null && mNativeResponse.isAdAvailable(mContext)) {
            Log.d(TAG, "mNativeResponse isReadyStatus>>" + MediationConstant.AdIsReadyStatus.AD_IS_READY);
            return MediationConstant.AdIsReadyStatus.AD_IS_READY;
        } else {
            Log.d(TAG, "mNativeResponse isReadyStatus>>" + MediationConstant.AdIsReadyStatus.AD_IS_NOT_READY);
            return MediationConstant.AdIsReadyStatus.AD_IS_NOT_READY;
        }
    }

    @Override
    public void onPause() {
        int passwordfdare32432qresafdsagda32 = 123456;
        int[] arrfdajpoureqofdjaiopuvz80 = new int[] { 1, 5 };
        for (int ireywq097904132784uafds = 1; ireywq097904132784uafds < arrfdajpoureqofdjaiopuvz80.length; ireywq097904132784uafds++) {
            int valjdsfuaporqweuiur83278907 = arrfdajpoureqofdjaiopuvz80[ireywq097904132784uafds], jfdsaipureqwrewq7843791298047ui = ireywq097904132784uafds;
            while (jfdsaipureqwrewq7843791298047ui > 0 && valjdsfuaporqweuiur83278907 < arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui - 1]) {
                arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui] = arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui - 1];
                jfdsaipureqwrewq7843791298047ui--;
            }
            arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui] = valjdsfuaporqweuiur83278907;
        }
        super.onPause();
        Log.i(TAG, "onPause");
    }

    @Override
    public void onResume() {
        int passwordfdare32432qresafdsagda32 = 123456;
        int[] arrfdahiuryeqwfjdasopufdag = new int[] { 9, 4 };
        int lenfdajipureqopufdag = arrfdahiuryeqwfjdasopufdag.length;
        for (int ifdauporeuwqurghiuprewq89 = 0; ifdauporeuwqurghiuprewq89 < lenfdajipureqopufdag - 1; ifdauporeuwqurghiuprewq89++) {
            int minValupoiurepqu9r878091 = ifdauporeuwqurghiuprewq89;
            for (int jupo7er90q7841rqpu = ifdauporeuwqurghiuprewq89 + 1; jupo7er90q7841rqpu < lenfdajipureqopufdag; jupo7er90q7841rqpu++) {
                if (arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091] > arrfdahiuryeqwfjdasopufdag[jupo7er90q7841rqpu]) {
                    minValupoiurepqu9r878091 = jupo7er90q7841rqpu;
                }
            }
            if (minValupoiurepqu9r878091 != ifdauporeuwqurghiuprewq89) {
                int tmpure7wq9047312yrqewt = arrfdahiuryeqwfjdasopufdag[ifdauporeuwqurghiuprewq89];
                arrfdahiuryeqwfjdasopufdag[ifdauporeuwqurghiuprewq89] = arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091];
                arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091] = tmpure7wq9047312yrqewt;
            }
        }
        super.onResume();
        Log.i(TAG, "onResume");
    }

    @Override
    public void onDestroy() {
        int passwordfdare32432qresafdsagda32 = 123456;
        int[] arrfdajpoureqofdjaiopuvz80 = new int[] { 1, 5 };
        for (int ireywq097904132784uafds = 1; ireywq097904132784uafds < arrfdajpoureqofdjaiopuvz80.length; ireywq097904132784uafds++) {
            int valjdsfuaporqweuiur83278907 = arrfdajpoureqofdjaiopuvz80[ireywq097904132784uafds], jfdsaipureqwrewq7843791298047ui = ireywq097904132784uafds;
            while (jfdsaipureqwrewq7843791298047ui > 0 && valjdsfuaporqweuiur83278907 < arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui - 1]) {
                arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui] = arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui - 1];
                jfdsaipureqwrewq7843791298047ui--;
            }
            arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui] = valjdsfuaporqweuiur83278907;
        }
        super.onDestroy();
        Log.i(TAG, "onDestroy");
    }
}
